define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'fffacc/index',
                    add_url: 'fffacc/add',
                    edit_url: 'fffacc/edit',
                    del_url: 'fffacc/del',
                    multi_url: 'fffacc/multi',
                    table: 'fff_acc',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'openid', title: __('Openid')},
                        {field: 'token', title: __('Token')},
                        {field: 'session', title: __('Session')},
                        {field: 'nick_name', title: __('Nick_name')},
                        {field: 'avatar_url', title: __('Avatar_url'), formatter: Table.api.formatter.url},
                        {field: 'stage', title: __('Stage')},
                        {field: 'coin', title: __('Coin')},
                        {field: 'diamond', title: __('Diamond')},
                        {field: 'stamina', title: __('Stamina')},
                        {field: 'guidance', title: __('Guidance')},
                        {field: 'logout_time', title: __('Logout_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'sign_in_num', title: __('Sign_in_num')},
                        {field: 'is_sign_in', title: __('Is_sign_in')},
                        {field: 'lucky_wheel_num', title: __('Lucky_wheel_num')},
                        {field: 'lucky_wheel_video', title: __('Lucky_wheel_video')},
                        {field: 'use_weapon', title: __('Use_weapon')},
                        {field: 'use_skin', title: __('Use_skin')},
                        {field: 'skin_list', title: __('Skin_list')},
                        {field: 'fire_rate', title: __('Fire_rate')},
                        {field: 'fire_power', title: __('Fire_power')},
                        {field: 'coin_value', title: __('Coin_value')},
                        {field: 'daily_income', title: __('Daily_income')},
                        {field: 'enter_xcx_award', title: __('Enter_xcx_award')},
                        {field: 'game_num', title: __('Game_num')},
                        {field: 'resurrect_num', title: __('Resurrect_num')},
                        {field: 'block_num', title: __('Block_num')},
                        {field: 'share_num', title: __('Share_num')},
                        {field: 'login_day_num', title: __('Login_day_num')},
                        {field: 'max_score', title: __('Max_score')},
                        {field: 'all_score', title: __('All_score')},
                        {field: 'live_second', title: __('Live_second')},
                        {field: 'share_user_num', title: __('Share_user_num')},
                        {field: 'life_coin', title: __('Life_coin')},
                        {field: 'bullet_skin', title: __('Bullet_skin')},
                        {field: 'plane_skin', title: __('Plane_skin')},
                        {field: 'last_login_time', title: __('Last_login_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'channel', title: __('Channel')},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});